﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data;

namespace NJL.WebUsers
{
    public partial class Attractions : BasePageVisitor
    {
        private readonly BLL.NJL_ATTRACTION bll = new BLL.NJL_ATTRACTION();
        private readonly BLL.NJL_TRIP_LINE bllTrip = new BLL.NJL_TRIP_LINE();
        private readonly BLL.NJL_COMPANY bllCompany = new BLL.NJL_COMPANY();
        private readonly BLL.NJL_CS_TAG bllTag = new BLL.NJL_CS_TAG();
        private readonly BLL.NJL_NEWS bllNews = new BLL.NJL_NEWS();
        private readonly BLL.NJL_SYS_NEWS bllSysNews = new BLL.NJL_SYS_NEWS();
        private readonly BLL.NJL_LOCAL_COLOR bllLocalColor = new BLL.NJL_LOCAL_COLOR();
        private readonly BLL.NJL_COMPANY_SERVICE bllCompanyService = new BLL.NJL_COMPANY_SERVICE();
        protected BLL.NJL_CS_AREA bllArea = new BLL.NJL_CS_AREA();
        protected IList<Model.NJL_ATTRACTION> LIST_ATTRACTION;
        protected IList<Model.NJL_ATTRACTION> LIST_ATTRACTION_NEAR;//周边景点
        protected IList<Model.NJL_TRIP_LINE> LIST_TRIP_LINE;
        protected IList<Model.NJL_COMPANY> LIST_COMPANY_1;
        protected IList<Model.NJL_COMPANY> LIST_COMPANY_2;
        protected IList<Model.NJL_COMPANY> LIST_COMPANY_NEAR;

        protected IList<Model.NJL_SYS_NEWS> LIST_FLASH;
        protected IList<Model.NJL_CS_TAG> LIST_TAG;
        protected IList<Model.NJL_NEWS> LIST_NEWS;

        protected IList<Model.NJL_COMPANY> LIST_COMPANY_HOT_2;
        protected IList<Model.NJL_LOCAL_COLOR> LIST_LOCAL_COLOR;
        protected IList<Model.NJL_COMPANY_SERVICE> LIST_SERVICE_HOT;
        public IList<Model.NJL_ATTRACTION> hotatt;
        DataSet ds;
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                txtKeywords.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + Button1.ClientID + "').click();return false;}} else {return true}; ");
            }
                LoadData();
                base.LoadPageSeoInformation("景点名胜");            
        }
        private void LoadData()
        {
            if ("" != WEBSITE_FOCUS_CITY_CODE)
            {
                LIST_FLASH = bllSysNews.GetModelList(10, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND IS_PUBLISH=1 AND IS_INDEX=1 AND TYPE_CODE='15' ", "SORT DESC,PUBLISH_DATE_TIME DESC");

                LIST_ATTRACTION = bll.GetModelList(8, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "' AND IS_PUBLISH=1 ", "SORT DESC,ID desc"); //景点
                LIST_ATTRACTION_NEAR = bll.GetModelList(8, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and AREA_CODE<>'" + WEBSITE_FOCUS_CITY_CODE + "' AND IS_PUBLISH=1 ", "SORT DESC,ID desc");

                LIST_TRIP_LINE = bllTrip.GetModelList(10, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' ", "ID desc ");

                LIST_COMPANY_1 = bllCompany.GetModelList(4, " NJL_COMPANY.NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and NJL_COMPANY.AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "' AND NJL_COMPANY.TYPE_CODE='1' ", "NJL_COMPANY.SORT DESC,NJL_COMPANY.ID desc");
                LIST_COMPANY_2 = bllCompany.GetModelList(4, " NJL_COMPANY.NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and NJL_COMPANY.AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "' AND NJL_COMPANY.TYPE_CODE='2' ", "NJL_COMPANY.SORT DESC,NJL_COMPANY.ID desc");

                #region 标签
                LIST_TAG = bllTag.GetModelList(15, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and TAG_TYPE='1' and AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "'", "SEARCH_COUNT desc,USED_COUNT DESC");
                #endregion

                #region 旅游攻略
                LIST_NEWS = bllNews.GetModelList(5, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "'", "CREATE_DATE_TIME DESC");
                #endregion

                #region 热门景点

                hotatt = bll.GetModelList(3, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "' AND IS_PUBLISH=1 ", "SORT DESC,ID desc");
                #endregion

                #region 咨询
                ds = bllSysNews.GetList(8, "NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and  TYPE_CODE='37' and IS_PUBLISH=1 ", "SORT DESC,PUBLISH_DATE_TIME desc");
                rptNews.DataSource = ds;
                rptNews.DataBind();
                #endregion

                #region 特产
                LIST_LOCAL_COLOR = bllLocalColor.GetModelList(3, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "' AND IS_PUBLISH=1 ", "SORT DESC,ID desc");
                #endregion

                #region 周边农户
                LIST_COMPANY_NEAR = bllCompany.GetModelList(4, " NJL_COMPANY.NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and NJL_COMPANY.AREA_CODE<>'" + WEBSITE_FOCUS_CITY_CODE + "' ", "NJL_COMPANY.SORT DESC,NJL_COMPANY.ID");
                #endregion

                #region 热评服务
                LIST_SERVICE_HOT = bllCompanyService.GetModelList(10, " NJL_COMPANY_ID IN(select ID From NJL_COMPANY where AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "')", "SORT DESC,ID DESC");
                #endregion
            }
            else
            {
                LIST_FLASH = bllSysNews.GetModelList(10, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND IS_PUBLISH=1 AND IS_INDEX=1 AND TYPE_CODE='15' ", "SORT DESC,PUBLISH_DATE_TIME DESC");

                LIST_ATTRACTION = bll.GetModelList(8, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND IS_PUBLISH=1 ", "SORT DESC,ID"); //景点
                LIST_ATTRACTION_NEAR = bll.GetModelList(8, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND IS_PUBLISH=1 ", "SORT DESC,ID");

                LIST_TRIP_LINE = bllTrip.GetModelList(10, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' ", "ID desc ");

                LIST_COMPANY_1 = bllCompany.GetModelList(4, " NJL_COMPANY.NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND NJL_COMPANY.TYPE_CODE='1' ", "NJL_COMPANY.SORT DESC,NJL_COMPANY.ID");
                LIST_COMPANY_2 = bllCompany.GetModelList(4, " NJL_COMPANY.NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND NJL_COMPANY.TYPE_CODE='2' ", "NJL_COMPANY.SORT DESC,NJL_COMPANY.ID");

                #region 标签
                LIST_TAG = bllTag.GetModelList(15, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and TAG_TYPE='1' ", "SEARCH_COUNT desc,USED_COUNT DESC");
                #endregion

                #region 旅游攻略
                LIST_NEWS = bllNews.GetModelList(5, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "'", "CREATE_DATE_TIME DESC");
                #endregion

                #region 热门景点

                hotatt = bll.GetModelList(3, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND IS_PUBLISH=1 ", "SORT DESC,ID desc");
                #endregion

                #region 咨询
                ds = bllSysNews.GetList(8, "NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and  TYPE_CODE='37' and IS_PUBLISH=1 ", "SORT DESC,PUBLISH_DATE_TIME desc");
                rptNews.DataSource = ds;
                rptNews.DataBind();
                #endregion

                #region 特产
                LIST_LOCAL_COLOR = bllLocalColor.GetModelList(3, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND IS_PUBLISH=1 ", "SORT DESC,ID desc");
                #endregion

                #region 周边农户
                LIST_COMPANY_NEAR = bllCompany.GetModelList(4, " NJL_COMPANY.NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and NJL_COMPANY.AREA_CODE<>'" + WEBSITE_FOCUS_CITY_CODE + "' ", "NJL_COMPANY.SORT DESC,NJL_COMPANY.ID");
                #endregion

                #region 热评服务
                LIST_SERVICE_HOT = bllCompanyService.GetModelList(10, " NJL_COMPANY_ID IN(select ID From NJL_COMPANY where NJL_SYS_BASE_ID='" + WEBSITE_CODE + "')", "SORT DESC,ID DESC");
                #endregion
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/SearchAttractions.aspx?keywords="+txtKeywords.Text.Trim()+"&cc=" + WEBSITE_FOCUS_CITY_NAME_PINYIN);
        }

   
    }
}